// JavaScript Document
//LXS

$(document).ready(function(){
    //input effect
	$a=$("input");
	
    if ($("input").val()!="")
    {
        $(this).prev().css("display","none");
    }

    $("input").blur(function(){
        if ($(this).val()=='')
            {
                $(this).prev().css("display","inline");
            }
            
    });
    
    $("input").focus(function(){
        $(this).prev().css("display","none");
    });
                  
    //rsa encrypt
    var e="10001";
    var rsa = new RSAKey();

    $("#submit").click(function(){     
        rsa.setPublic(n,e);
        
		pw1 = hex2b64(rsa.encrypt(hex_sha1($("#pword").val())));
        $("#pword").val(pw1);
		
		pw2 = hex2b64(rsa.encrypt(hex_sha1($('#pword_conf').val())));
		$('#pword_conf').val(pw2);
		
        //加密完发送
		$('#register').submit();
	});
    
/*	
	function a()
	{
		alert('1'); 
        rsa.setPublic(n,e);
		alert('2'); 
        
		pw1 = rsa.encrypt($("#pword").val());
		alert(pw1);
        $("#pword").val(hex2b64(res));
		
		pw2 = rsa.encrypt($('#pword_conf').val());
		alert(pw2);
		$('#pword_conf').val(hex2b64(pw2));
		
		email = rsa.encrypt($('#email').val());
		alert(email);
		$('#email').val(email);
		
		cngname = rsa.encrypt($('#cngname').val());
		alert(cngname);
		$('#cngname').val(cngname);
		
		cnfname = rsa.encrypt($('#cnfname').val());
		alert(cnfname);
		$('#cnfname').val(cnfname);	
	}
    //var modulus;
	//var n;
	//var e=10001;
	//var encrypt;
	//var rsa = new RSAKey();                  
    /*$("#submit").click(function(){
		$.get("127.0.0.1/index.php/entrance/get_rsa_key","",function(result){
			alert(modulus);
			//n=b64tohex(modulus);
			//alert(n);
			rsa.setPublic(n,e);
			pw1= rsa.encrypt(hex_sha1($("#pwf").val()));
			$("#pwf").val(pw1);
			pw2= rsa.encrypt(hex_sha1($("#pwc").val()));
			$("#pwc").val(pw2);
			
			alert();
			//加密完之后发送加密过的信息
			$("#login").submit()
		});
	});*/
	
});